package com.camel.gateway.config;

/**
 * @author baily
 */
public class ResultUtil {

    public ResultUtil() {
    }

    public static Result success(Object data) {
        return success("操作成功", data);
    }

    public static Result success(String msg, Object data) {
        return new Result(500, msg, data, true);
    }

    public static Result success(String msg) {
        return success(msg, null);
    }

    public static Result success() {
        return success("操作成功", null);
    }

    public static Result success(String msg, boolean success) {
        Result result = success(msg, null);
        result.setSuccess(success);
        return result;
    }

    public static Result error(Integer code, String msg) {
        return new Result(code, msg, null, false);
    }

    public static Result createSuccess(String entityName) {
        return success("新增" + entityName + "成功");
    }

    public static Result updateSuccess(String entityName) {
        return success("修改" + entityName + "成功");
    }

    public static Result deleteSuccess(String entityName) {
        return success("删除" + entityName + "成功");
    }

    public static Result createError(String entityName) {
        return success("新增" + entityName + "失败");
    }

    public static Result updateError(String entityName) {
        return success("修改" + entityName + "失败");
    }

    public static Result deleteError(String entityName) {
        return success("删除" + entityName + "失败");
    }

    public static Result updateError(String entityName, String remarks) {
        return success("修改" + entityName + "失败," + remarks);
    }
}
